package cn.mccraft.uide.api.plugin.extension;

import java.net.URL;
import java.util.Optional;

import javax.annotation.Nonnull;

import com.google.common.reflect.TypeToken;
import com.google.gson.JsonObject;

import cn.mccraft.uide.api.element.Element;
import cn.mccraft.uide.api.project.Project;
import ro.fortsoft.pf4j.ExtensionPoint;

public interface ElementProvider<T extends Element> extends ExtensionPoint {

	@Nonnull
	default TypeToken<T> getType() {
		return new TypeToken<T>() {};
	}

	Optional<T> createElement(Project project, String name);
	
	Optional<T> loadElement(Project project, JsonObject jsonObject);

	@Nonnull
	String getElementName();

	@Nonnull
	String getLocalizedElementName();

	Optional<URL> getElementIcon();
}
